{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "6eNOTF0z1ql2"
   },
   "source": [
    "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
    "\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/healthcare/relation_extraction/overview_relation.ipynb)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ZgUZduDZVTgN"
   },
   "source": [
    "# Extract **relationships** between **named entities**\n",
    "With the *Named Entity Recognizer** models provided by NLU you can extract various named entities from you dataset, like `disease` and `medicine` names, `treatments` , `tests` , `patient names` etc..\n",
    "\n",
    "Between these `entities` there can exist some relation.\n",
    "For example, the sentence :  \n",
    "\"`Timmys` had a `headache` , it was treated with `paracetamol` by `Dr Sami` \"   ,\n",
    "\n",
    "it has the named entities `Dr Sami` , `Timmy` , `headache` , `paracetamol`   and these entities have some relation between them.\n",
    "\n",
    "- The entity `Timmy` is related to `headache` ,  with a `has` relationship\n",
    "- The entity `headache` is related to `paracetamol` with a `is treated with` relation ship\n",
    "\n",
    "\n",
    "The **Relation Extractor** models classifies for each pair for entities, wether some kind of relationship exists between them.\n",
    "\n",
    "All the models avaiable are :\n",
    "\n",
    "| Language | nlp.load() reference                                         | Spark NLP Model reference          |\n",
    "| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |\n",
    "| English  | [assert](https://nlp.johnsnowlabs.com/2021/01/26/assertion_dl_en.html) | [assertion_dl](https://nlp.johnsnowlabs.com/2021/01/26/assertion_dl_en.html)                   |\n",
    "| English  | [assert.biobert](https://nlp.johnsnowlabs.com/2021/01/26/assertion_dl_biobert_en.html) | [assertion_dl_biobert](https://nlp.johnsnowlabs.com/2021/01/26/assertion_dl_biobert_en.html)                   |\n",
    "| English  | [assert.healthcare](https://nlp.johnsnowlabs.com/2020/09/23/assertion_dl_healthcare_en.html) | [assertion_dl_healthcare](https://nlp.johnsnowlabs.com/2020/09/23/assertion_dl_healthcare_en.html)                   |\n",
    "| English  | [assert.large](https://nlp.johnsnowlabs.com/2020/05/21/assertion_dl_large_en.html) | [assertion_dl_large](https://nlp.johnsnowlabs.com/2020/05/21/assertion_dl_large_en.html)                   |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "OMiHjCtQhF_r"
   },
   "outputs": [],
   "source": [
    "# Install the johnsnowlabs library\n",
    "! pip install -q johnsnowlabs==5.1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "xaj9_b2SQtI-"
   },
   "outputs": [],
   "source": [
    "from google.colab import files\n",
    "print('Please Upload your John Snow Labs License using the button below')\n",
    "license_keys = files.upload()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "sXByDlEaQtMn"
   },
   "outputs": [],
   "source": [
    "from johnsnowlabs import nlp\n",
    "\n",
    "# After uploading your license run this to install all licensed Python Wheels and pre-download Jars the Spark Session JVM\n",
    "nlp.install()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "BFOXG7HjQtOo"
   },
   "outputs": [],
   "source": [
    "from johnsnowlabs import nlp\n",
    "\n",
    "spark=nlp.start()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "T608HnSAiHVu"
   },
   "source": [
    "#### [Relation extraction between body parts and direction entities (ReDL).](https://nlp.johnsnowlabs.com/2021/02/04/redl_bodypart_direction_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "SGdSUgz5hcEh",
    "outputId": "9579447b-3f66-4170-9d09-3d664ae2a8b7"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "jsl_ner_wip_greedy_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_bodypart_direction_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-13e7891c-1660-428e-8805-9960fb168d13\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_jsl</th>\n",
       "      <th>entities_jsl_class</th>\n",
       "      <th>entities_jsl_confidence</th>\n",
       "      <th>entities_jsl_origin_chunk</th>\n",
       "      <th>entities_jsl_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.8694523</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9348048</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.5009316</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.94379485</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.8576839</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9617076</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.87278575</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9500059</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.55088794</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.95743227</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9379284</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9697915</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9307682</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99998033</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.98367107</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.96962243</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9878457</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.96080923</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.53186274</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.6206263</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.8491103</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.6162882</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.9999045</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9841017</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9443719</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.97302264</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9132868</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.9999565</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-13e7891c-1660-428e-8805-9960fb168d13')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-13e7891c-1660-428e-8805-9960fb168d13 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-13e7891c-1660-428e-8805-9960fb168d13');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-1d4a562e-6144-4fbc-b300-5be78e04ebae\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-1d4a562e-6144-4fbc-b300-5be78e04ebae')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-1d4a562e-6144-4fbc-b300-5be78e04ebae button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "\n",
       "                                        entities_jsl  \\\n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "\n",
       "                                  entities_jsl_class  \\\n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "\n",
       "                             entities_jsl_confidence  \\\n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "\n",
       "  entities_jsl_origin_chunk entities_jsl_origin_sentence relation  \\\n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "\n",
       "  relation_confidence relation_entity1 relation_entity1_begin  \\\n",
       "0           0.8694523              MRI                      0   \n",
       "0           0.9348048              MRI                      0   \n",
       "0           0.5009316              MRI                      0   \n",
       "0          0.94379485              MRI                      0   \n",
       "0           0.8576839              MRI                      0   \n",
       "0           0.9617076              MRI                      0   \n",
       "0          0.87278575              MRI                      0   \n",
       "0           0.9500059       infarction                     17   \n",
       "0          0.55088794       infarction                     17   \n",
       "0          0.95743227       infarction                     17   \n",
       "0           0.9379284       infarction                     17   \n",
       "0           0.9697915       infarction                     17   \n",
       "0           0.9307682       infarction                     17   \n",
       "0          0.99998033            upper                     35   \n",
       "0          0.98367107            upper                     35   \n",
       "0          0.96962243            upper                     35   \n",
       "0           0.9878457            upper                     35   \n",
       "0          0.96080923            upper                     35   \n",
       "0          0.53186274       brain stem                     41   \n",
       "0           0.6206263       brain stem                     41   \n",
       "0           0.8491103       brain stem                     41   \n",
       "0           0.6162882       brain stem                     41   \n",
       "0           0.9999045             left                     54   \n",
       "0           0.9841017             left                     54   \n",
       "0           0.9443719             left                     54   \n",
       "0          0.97302264       cerebellum                     59   \n",
       "0           0.9132868       cerebellum                     59   \n",
       "0           0.9999565            right                     74   \n",
       "\n",
       "        relation_entity1_class relation_entity1_end relation_entity2  \\\n",
       "0                         Test                    2       infarction   \n",
       "0                         Test                    2            upper   \n",
       "0                         Test                    2       brain stem   \n",
       "0                         Test                    2             left   \n",
       "0                         Test                    2       cerebellum   \n",
       "0                         Test                    2            right   \n",
       "0                         Test                    2    basil ganglia   \n",
       "0    Disease_Syndrome_Disorder                   26            upper   \n",
       "0    Disease_Syndrome_Disorder                   26       brain stem   \n",
       "0    Disease_Syndrome_Disorder                   26             left   \n",
       "0    Disease_Syndrome_Disorder                   26       cerebellum   \n",
       "0    Disease_Syndrome_Disorder                   26            right   \n",
       "0    Disease_Syndrome_Disorder                   26    basil ganglia   \n",
       "0                    Direction                   39       brain stem   \n",
       "0                    Direction                   39             left   \n",
       "0                    Direction                   39       cerebellum   \n",
       "0                    Direction                   39            right   \n",
       "0                    Direction                   39    basil ganglia   \n",
       "0  Internal_organ_or_component                   50             left   \n",
       "0  Internal_organ_or_component                   50       cerebellum   \n",
       "0  Internal_organ_or_component                   50            right   \n",
       "0  Internal_organ_or_component                   50    basil ganglia   \n",
       "0                    Direction                   57       cerebellum   \n",
       "0                    Direction                   57            right   \n",
       "0                    Direction                   57    basil ganglia   \n",
       "0  Internal_organ_or_component                   68            right   \n",
       "0  Internal_organ_or_component                   68    basil ganglia   \n",
       "0                    Direction                   78    basil ganglia   \n",
       "\n",
       "  relation_entity2_begin       relation_entity2_class relation_entity2_end  \\\n",
       "0                     17    Disease_Syndrome_Disorder                   26   \n",
       "0                     35                    Direction                   39   \n",
       "0                     41  Internal_organ_or_component                   50   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     35                    Direction                   39   \n",
       "0                     41  Internal_organ_or_component                   50   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     41  Internal_organ_or_component                   50   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "\n",
       "  relation_origin_sentence                               word_embedding_glove  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.jsl.wip.clinical.greedy en.relation').predict('MRI demonstrated infarction in the upper brain stem , left cerebellum and  right basil ganglia\"', output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Q3EDsgFWwc18"
   },
   "source": [
    "#### [Relation extraction between body parts and problem entities (ReDL)](https://nlp.johnsnowlabs.com/2021/02/04/redl_bodypart_problem_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "4heRoNuEiuTc",
    "outputId": "0a2db51a-df8d-4489-d9ae-cf556e45fb17"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "jsl_ner_wip_greedy_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_bodypart_problem_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-5a35a192-ceaa-42ad-a630-adb1931bde3d\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_jsl</th>\n",
       "      <th>entities_jsl_class</th>\n",
       "      <th>entities_jsl_confidence</th>\n",
       "      <th>entities_jsl_origin_chunk</th>\n",
       "      <th>entities_jsl_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.55153555</td>\n",
       "      <td>neurologic deficits</td>\n",
       "      <td>3</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>21</td>\n",
       "      <td>numbness</td>\n",
       "      <td>39</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>46</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.76366574</td>\n",
       "      <td>neurologic deficits</td>\n",
       "      <td>3</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>21</td>\n",
       "      <td>his</td>\n",
       "      <td>51</td>\n",
       "      <td>Gender</td>\n",
       "      <td>53</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.7297143</td>\n",
       "      <td>neurologic deficits</td>\n",
       "      <td>3</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>21</td>\n",
       "      <td>left</td>\n",
       "      <td>55</td>\n",
       "      <td>Direction</td>\n",
       "      <td>58</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.75410986</td>\n",
       "      <td>neurologic deficits</td>\n",
       "      <td>3</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>21</td>\n",
       "      <td>hand</td>\n",
       "      <td>60</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99978477</td>\n",
       "      <td>numbness</td>\n",
       "      <td>39</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>46</td>\n",
       "      <td>his</td>\n",
       "      <td>51</td>\n",
       "      <td>Gender</td>\n",
       "      <td>53</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99973446</td>\n",
       "      <td>numbness</td>\n",
       "      <td>39</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>46</td>\n",
       "      <td>left</td>\n",
       "      <td>55</td>\n",
       "      <td>Direction</td>\n",
       "      <td>58</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99973387</td>\n",
       "      <td>numbness</td>\n",
       "      <td>39</td>\n",
       "      <td>Symptom</td>\n",
       "      <td>46</td>\n",
       "      <td>hand</td>\n",
       "      <td>60</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.9985876</td>\n",
       "      <td>his</td>\n",
       "      <td>51</td>\n",
       "      <td>Gender</td>\n",
       "      <td>53</td>\n",
       "      <td>left</td>\n",
       "      <td>55</td>\n",
       "      <td>Direction</td>\n",
       "      <td>58</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99891603</td>\n",
       "      <td>his</td>\n",
       "      <td>51</td>\n",
       "      <td>Gender</td>\n",
       "      <td>53</td>\n",
       "      <td>hand</td>\n",
       "      <td>60</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>No neurologic deficits other than some numbnes...</td>\n",
       "      <td>[neurologic deficits, numbness, his, left, hand]</td>\n",
       "      <td>[Symptom, Symptom, Gender, Direction, External...</td>\n",
       "      <td>[0.5703, 0.9583, 0.8946, 0.3636, 0.6644]</td>\n",
       "      <td>[0, 1, 2, 3, 4]</td>\n",
       "      <td>[0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99917585</td>\n",
       "      <td>left</td>\n",
       "      <td>55</td>\n",
       "      <td>Direction</td>\n",
       "      <td>58</td>\n",
       "      <td>hand</td>\n",
       "      <td>60</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.31757616996765137, -0.1074424758553505, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-5a35a192-ceaa-42ad-a630-adb1931bde3d')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-5a35a192-ceaa-42ad-a630-adb1931bde3d button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-5a35a192-ceaa-42ad-a630-adb1931bde3d');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-405355d5-daea-48ab-aca3-eed005256984\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-405355d5-daea-48ab-aca3-eed005256984')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-405355d5-daea-48ab-aca3-eed005256984 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "0  No neurologic deficits other than some numbnes...   \n",
       "\n",
       "                                       entities_jsl  \\\n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "0  [neurologic deficits, numbness, his, left, hand]   \n",
       "\n",
       "                                  entities_jsl_class  \\\n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "0  [Symptom, Symptom, Gender, Direction, External...   \n",
       "\n",
       "                    entities_jsl_confidence entities_jsl_origin_chunk  \\\n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "0  [0.5703, 0.9583, 0.8946, 0.3636, 0.6644]           [0, 1, 2, 3, 4]   \n",
       "\n",
       "  entities_jsl_origin_sentence relation relation_confidence  \\\n",
       "0              [0, 0, 0, 0, 0]        1          0.55153555   \n",
       "0              [0, 0, 0, 0, 0]        1          0.76366574   \n",
       "0              [0, 0, 0, 0, 0]        1           0.7297143   \n",
       "0              [0, 0, 0, 0, 0]        0          0.75410986   \n",
       "0              [0, 0, 0, 0, 0]        1          0.99978477   \n",
       "0              [0, 0, 0, 0, 0]        1          0.99973446   \n",
       "0              [0, 0, 0, 0, 0]        1          0.99973387   \n",
       "0              [0, 0, 0, 0, 0]        1           0.9985876   \n",
       "0              [0, 0, 0, 0, 0]        1          0.99891603   \n",
       "0              [0, 0, 0, 0, 0]        1          0.99917585   \n",
       "\n",
       "      relation_entity1 relation_entity1_begin relation_entity1_class  \\\n",
       "0  neurologic deficits                      3                Symptom   \n",
       "0  neurologic deficits                      3                Symptom   \n",
       "0  neurologic deficits                      3                Symptom   \n",
       "0  neurologic deficits                      3                Symptom   \n",
       "0             numbness                     39                Symptom   \n",
       "0             numbness                     39                Symptom   \n",
       "0             numbness                     39                Symptom   \n",
       "0                  his                     51                 Gender   \n",
       "0                  his                     51                 Gender   \n",
       "0                 left                     55              Direction   \n",
       "\n",
       "  relation_entity1_end relation_entity2 relation_entity2_begin  \\\n",
       "0                   21         numbness                     39   \n",
       "0                   21              his                     51   \n",
       "0                   21             left                     55   \n",
       "0                   21             hand                     60   \n",
       "0                   46              his                     51   \n",
       "0                   46             left                     55   \n",
       "0                   46             hand                     60   \n",
       "0                   53             left                     55   \n",
       "0                   53             hand                     60   \n",
       "0                   58             hand                     60   \n",
       "\n",
       "         relation_entity2_class relation_entity2_end relation_origin_sentence  \\\n",
       "0                       Symptom                   46                        0   \n",
       "0                        Gender                   53                        0   \n",
       "0                     Direction                   58                        0   \n",
       "0  External_body_part_or_region                   63                        0   \n",
       "0                        Gender                   53                        0   \n",
       "0                     Direction                   58                        0   \n",
       "0  External_body_part_or_region                   63                        0   \n",
       "0                     Direction                   58                        0   \n",
       "0  External_body_part_or_region                   63                        0   \n",
       "0  External_body_part_or_region                   63                        0   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  \n",
       "0  [[-0.31757616996765137, -0.1074424758553505, 0...  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.jsl.wip.clinical.greedy en.relation.bodypart.problem').predict(\"No neurologic deficits other than some numbness in his left hand.\", output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Jde3GStIxI4A"
   },
   "source": [
    "#### [Relation extraction between body parts and procedures](https://nlp.johnsnowlabs.com/2021/02/04/redl_bodypart_procedure_test_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 952
    },
    "id": "py3WMEBdxI4B",
    "outputId": "245b3c82-9ee7-48a9-c2b0-039eee68c07c"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "jsl_ner_wip_greedy_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_bodypart_procedure_test_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-1f5e623e-2223-47e3-9b9d-18258db7b7f9\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_jsl</th>\n",
       "      <th>entities_jsl_class</th>\n",
       "      <th>entities_jsl_confidence</th>\n",
       "      <th>entities_jsl_origin_chunk</th>\n",
       "      <th>entities_jsl_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TECHNIQUE IN DETAIL: After informed consent wa...</td>\n",
       "      <td>[TECHNIQUE IN DETAIL:, his mother, chest, port...</td>\n",
       "      <td>[Section_Header, Gender, External_body_part_or...</td>\n",
       "      <td>[0.436275, 0.84725, 0.8873, 0.3765]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.9969105</td>\n",
       "      <td>TECHNIQUE IN DETAIL:</td>\n",
       "      <td>0</td>\n",
       "      <td>Section_Header</td>\n",
       "      <td>19</td>\n",
       "      <td>his mother</td>\n",
       "      <td>78</td>\n",
       "      <td>Gender</td>\n",
       "      <td>87</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.278702974319458, 0.49658653140068054, -0.1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TECHNIQUE IN DETAIL: After informed consent wa...</td>\n",
       "      <td>[TECHNIQUE IN DETAIL:, his mother, chest, port...</td>\n",
       "      <td>[Section_Header, Gender, External_body_part_or...</td>\n",
       "      <td>[0.436275, 0.84725, 0.8873, 0.3765]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99992144</td>\n",
       "      <td>TECHNIQUE IN DETAIL:</td>\n",
       "      <td>0</td>\n",
       "      <td>Section_Header</td>\n",
       "      <td>19</td>\n",
       "      <td>chest</td>\n",
       "      <td>94</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>98</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.278702974319458, 0.49658653140068054, -0.1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TECHNIQUE IN DETAIL: After informed consent wa...</td>\n",
       "      <td>[TECHNIQUE IN DETAIL:, his mother, chest, port...</td>\n",
       "      <td>[Section_Header, Gender, External_body_part_or...</td>\n",
       "      <td>[0.436275, 0.84725, 0.8873, 0.3765]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99849284</td>\n",
       "      <td>TECHNIQUE IN DETAIL:</td>\n",
       "      <td>0</td>\n",
       "      <td>Section_Header</td>\n",
       "      <td>19</td>\n",
       "      <td>portable ultrasound</td>\n",
       "      <td>117</td>\n",
       "      <td>Test</td>\n",
       "      <td>135</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.278702974319458, 0.49658653140068054, -0.1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TECHNIQUE IN DETAIL: After informed consent wa...</td>\n",
       "      <td>[TECHNIQUE IN DETAIL:, his mother, chest, port...</td>\n",
       "      <td>[Section_Header, Gender, External_body_part_or...</td>\n",
       "      <td>[0.436275, 0.84725, 0.8873, 0.3765]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99995327</td>\n",
       "      <td>his mother</td>\n",
       "      <td>78</td>\n",
       "      <td>Gender</td>\n",
       "      <td>87</td>\n",
       "      <td>chest</td>\n",
       "      <td>94</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>98</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.278702974319458, 0.49658653140068054, -0.1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TECHNIQUE IN DETAIL: After informed consent wa...</td>\n",
       "      <td>[TECHNIQUE IN DETAIL:, his mother, chest, port...</td>\n",
       "      <td>[Section_Header, Gender, External_body_part_or...</td>\n",
       "      <td>[0.436275, 0.84725, 0.8873, 0.3765]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.9996624</td>\n",
       "      <td>his mother</td>\n",
       "      <td>78</td>\n",
       "      <td>Gender</td>\n",
       "      <td>87</td>\n",
       "      <td>portable ultrasound</td>\n",
       "      <td>117</td>\n",
       "      <td>Test</td>\n",
       "      <td>135</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.278702974319458, 0.49658653140068054, -0.1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TECHNIQUE IN DETAIL: After informed consent wa...</td>\n",
       "      <td>[TECHNIQUE IN DETAIL:, his mother, chest, port...</td>\n",
       "      <td>[Section_Header, Gender, External_body_part_or...</td>\n",
       "      <td>[0.436275, 0.84725, 0.8873, 0.3765]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.99994004</td>\n",
       "      <td>chest</td>\n",
       "      <td>94</td>\n",
       "      <td>External_body_part_or_region</td>\n",
       "      <td>98</td>\n",
       "      <td>portable ultrasound</td>\n",
       "      <td>117</td>\n",
       "      <td>Test</td>\n",
       "      <td>135</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.278702974319458, 0.49658653140068054, -0.1...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-1f5e623e-2223-47e3-9b9d-18258db7b7f9')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-1f5e623e-2223-47e3-9b9d-18258db7b7f9 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-1f5e623e-2223-47e3-9b9d-18258db7b7f9');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-251172b3-6007-4d47-bda3-365be26a2b56\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-251172b3-6007-4d47-bda3-365be26a2b56')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-251172b3-6007-4d47-bda3-365be26a2b56 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  TECHNIQUE IN DETAIL: After informed consent wa...   \n",
       "0  TECHNIQUE IN DETAIL: After informed consent wa...   \n",
       "0  TECHNIQUE IN DETAIL: After informed consent wa...   \n",
       "0  TECHNIQUE IN DETAIL: After informed consent wa...   \n",
       "0  TECHNIQUE IN DETAIL: After informed consent wa...   \n",
       "0  TECHNIQUE IN DETAIL: After informed consent wa...   \n",
       "\n",
       "                                        entities_jsl  \\\n",
       "0  [TECHNIQUE IN DETAIL:, his mother, chest, port...   \n",
       "0  [TECHNIQUE IN DETAIL:, his mother, chest, port...   \n",
       "0  [TECHNIQUE IN DETAIL:, his mother, chest, port...   \n",
       "0  [TECHNIQUE IN DETAIL:, his mother, chest, port...   \n",
       "0  [TECHNIQUE IN DETAIL:, his mother, chest, port...   \n",
       "0  [TECHNIQUE IN DETAIL:, his mother, chest, port...   \n",
       "\n",
       "                                  entities_jsl_class  \\\n",
       "0  [Section_Header, Gender, External_body_part_or...   \n",
       "0  [Section_Header, Gender, External_body_part_or...   \n",
       "0  [Section_Header, Gender, External_body_part_or...   \n",
       "0  [Section_Header, Gender, External_body_part_or...   \n",
       "0  [Section_Header, Gender, External_body_part_or...   \n",
       "0  [Section_Header, Gender, External_body_part_or...   \n",
       "\n",
       "               entities_jsl_confidence entities_jsl_origin_chunk  \\\n",
       "0  [0.436275, 0.84725, 0.8873, 0.3765]              [0, 1, 2, 3]   \n",
       "0  [0.436275, 0.84725, 0.8873, 0.3765]              [0, 1, 2, 3]   \n",
       "0  [0.436275, 0.84725, 0.8873, 0.3765]              [0, 1, 2, 3]   \n",
       "0  [0.436275, 0.84725, 0.8873, 0.3765]              [0, 1, 2, 3]   \n",
       "0  [0.436275, 0.84725, 0.8873, 0.3765]              [0, 1, 2, 3]   \n",
       "0  [0.436275, 0.84725, 0.8873, 0.3765]              [0, 1, 2, 3]   \n",
       "\n",
       "  entities_jsl_origin_sentence relation relation_confidence  \\\n",
       "0                 [0, 0, 0, 0]        1           0.9969105   \n",
       "0                 [0, 0, 0, 0]        1          0.99992144   \n",
       "0                 [0, 0, 0, 0]        1          0.99849284   \n",
       "0                 [0, 0, 0, 0]        1          0.99995327   \n",
       "0                 [0, 0, 0, 0]        1           0.9996624   \n",
       "0                 [0, 0, 0, 0]        1          0.99994004   \n",
       "\n",
       "       relation_entity1 relation_entity1_begin        relation_entity1_class  \\\n",
       "0  TECHNIQUE IN DETAIL:                      0                Section_Header   \n",
       "0  TECHNIQUE IN DETAIL:                      0                Section_Header   \n",
       "0  TECHNIQUE IN DETAIL:                      0                Section_Header   \n",
       "0            his mother                     78                        Gender   \n",
       "0            his mother                     78                        Gender   \n",
       "0                 chest                     94  External_body_part_or_region   \n",
       "\n",
       "  relation_entity1_end     relation_entity2 relation_entity2_begin  \\\n",
       "0                   19           his mother                     78   \n",
       "0                   19                chest                     94   \n",
       "0                   19  portable ultrasound                    117   \n",
       "0                   87                chest                     94   \n",
       "0                   87  portable ultrasound                    117   \n",
       "0                   98  portable ultrasound                    117   \n",
       "\n",
       "         relation_entity2_class relation_entity2_end relation_origin_sentence  \\\n",
       "0                        Gender                   87                        0   \n",
       "0  External_body_part_or_region                   98                        0   \n",
       "0                          Test                  135                        0   \n",
       "0  External_body_part_or_region                   98                        0   \n",
       "0                          Test                  135                        0   \n",
       "0                          Test                  135                        0   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[0.278702974319458, 0.49658653140068054, -0.1...  \n",
       "0  [[0.278702974319458, 0.49658653140068054, -0.1...  \n",
       "0  [[0.278702974319458, 0.49658653140068054, -0.1...  \n",
       "0  [[0.278702974319458, 0.49658653140068054, -0.1...  \n",
       "0  [[0.278702974319458, 0.49658653140068054, -0.1...  \n",
       "0  [[0.278702974319458, 0.49658653140068054, -0.1...  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.jsl.wip.clinical.greedy en.relation.bodypart.procedure').predict(\"TECHNIQUE IN DETAIL: After informed consent was obtained from the patient and his mother, the chest was scanned with portable ultrasound.\", output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "l5mCMZNhxLuf"
   },
   "source": [
    "#### [Extract relations between chemicals and proteins (ReDL)](https://nlp.johnsnowlabs.com/2021/02/04/redl_chemprot_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "zQBPjOqLxLug",
    "outputId": "7c359f0f-3683-4518-c0db-776705506e5e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_chemprot_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_chemprot_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-7f300364-bf91-4852-8ec4-736142a620da\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_chemprot</th>\n",
       "      <th>entities_chemprot_class</th>\n",
       "      <th>entities_chemprot_confidence</th>\n",
       "      <th>entities_chemprot_origin_chunk</th>\n",
       "      <th>entities_chemprot_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.9976648</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>42</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>52</td>\n",
       "      <td>channels</td>\n",
       "      <td>79</td>\n",
       "      <td>GENE-N</td>\n",
       "      <td>86</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.98735017</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>42</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>52</td>\n",
       "      <td>nateglinide</td>\n",
       "      <td>223</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>233</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:4</td>\n",
       "      <td>0.7207817</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>42</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>52</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>310</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>320</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.99456125</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>42</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>52</td>\n",
       "      <td>Nateglinide</td>\n",
       "      <td>542</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>552</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.99456125</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>42</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>52</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>705</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>715</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.57219946</td>\n",
       "      <td>sulfonylureas</td>\n",
       "      <td>1274</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1286</td>\n",
       "      <td>channel</td>\n",
       "      <td>1386</td>\n",
       "      <td>GENE-N</td>\n",
       "      <td>1392</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.57219946</td>\n",
       "      <td>sulfonylureas</td>\n",
       "      <td>1274</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1286</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>1412</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1422</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.57219946</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>1289</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1299</td>\n",
       "      <td>channel</td>\n",
       "      <td>1386</td>\n",
       "      <td>GENE-N</td>\n",
       "      <td>1392</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.57219946</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>1289</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1299</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>1412</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1422</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>In this study, we examined the effects of miti...</td>\n",
       "      <td>[mitiglinide, channels, nateglinide, mitiglini...</td>\n",
       "      <td>[CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...</td>\n",
       "      <td>[0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...</td>\n",
       "      <td>CPR:2</td>\n",
       "      <td>0.57219946</td>\n",
       "      <td>channel</td>\n",
       "      <td>1386</td>\n",
       "      <td>GENE-N</td>\n",
       "      <td>1392</td>\n",
       "      <td>mitiglinide</td>\n",
       "      <td>1412</td>\n",
       "      <td>CHEMICAL</td>\n",
       "      <td>1422</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.03855392336845398, -0.6488023400306702, -...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>406 rows × 18 columns</p>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-7f300364-bf91-4852-8ec4-736142a620da')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-7f300364-bf91-4852-8ec4-736142a620da button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-7f300364-bf91-4852-8ec4-736142a620da');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-b3992c8e-5f32-4a53-a85d-3f18610d7da1\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-b3992c8e-5f32-4a53-a85d-3f18610d7da1')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-b3992c8e-5f32-4a53-a85d-3f18610d7da1 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                             document  \\\n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "..                                                ...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "0   In this study, we examined the effects of miti...   \n",
       "\n",
       "                                    entities_chemprot  \\\n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "..                                                ...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "0   [mitiglinide, channels, nateglinide, mitiglini...   \n",
       "\n",
       "                              entities_chemprot_class  \\\n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "..                                                ...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "0   [CHEMICAL, GENE-N, CHEMICAL, CHEMICAL, CHEMICA...   \n",
       "\n",
       "                         entities_chemprot_confidence  \\\n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "..                                                ...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "0   [0.9712, 0.9939, 0.957, 0.9757, 0.9705, 0.9938...   \n",
       "\n",
       "                       entities_chemprot_origin_chunk  \\\n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "..                                                ...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...   \n",
       "\n",
       "                    entities_chemprot_origin_sentence relation  \\\n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:4   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "..                                                ...      ...   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...    CPR:2   \n",
       "\n",
       "   relation_confidence relation_entity1 relation_entity1_begin  \\\n",
       "0            0.9976648      mitiglinide                     42   \n",
       "0           0.98735017      mitiglinide                     42   \n",
       "0            0.7207817      mitiglinide                     42   \n",
       "0           0.99456125      mitiglinide                     42   \n",
       "0           0.99456125      mitiglinide                     42   \n",
       "..                 ...              ...                    ...   \n",
       "0           0.57219946    sulfonylureas                   1274   \n",
       "0           0.57219946    sulfonylureas                   1274   \n",
       "0           0.57219946      mitiglinide                   1289   \n",
       "0           0.57219946      mitiglinide                   1289   \n",
       "0           0.57219946          channel                   1386   \n",
       "\n",
       "   relation_entity1_class relation_entity1_end relation_entity2  \\\n",
       "0                CHEMICAL                   52         channels   \n",
       "0                CHEMICAL                   52      nateglinide   \n",
       "0                CHEMICAL                   52      mitiglinide   \n",
       "0                CHEMICAL                   52      Nateglinide   \n",
       "0                CHEMICAL                   52      mitiglinide   \n",
       "..                    ...                  ...              ...   \n",
       "0                CHEMICAL                 1286          channel   \n",
       "0                CHEMICAL                 1286      mitiglinide   \n",
       "0                CHEMICAL                 1299          channel   \n",
       "0                CHEMICAL                 1299      mitiglinide   \n",
       "0                  GENE-N                 1392      mitiglinide   \n",
       "\n",
       "   relation_entity2_begin relation_entity2_class relation_entity2_end  \\\n",
       "0                      79                 GENE-N                   86   \n",
       "0                     223               CHEMICAL                  233   \n",
       "0                     310               CHEMICAL                  320   \n",
       "0                     542               CHEMICAL                  552   \n",
       "0                     705               CHEMICAL                  715   \n",
       "..                    ...                    ...                  ...   \n",
       "0                    1386                 GENE-N                 1392   \n",
       "0                    1412               CHEMICAL                 1422   \n",
       "0                    1386                 GENE-N                 1392   \n",
       "0                    1412               CHEMICAL                 1422   \n",
       "0                    1412               CHEMICAL                 1422   \n",
       "\n",
       "   relation_origin_sentence                               word_embedding_glove  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "..                      ...                                                ...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "0                         0  [[-0.03855392336845398, -0.6488023400306702, -...  \n",
       "\n",
       "[406 rows x 18 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.chemprot.clinical en.relation.chemprot').predict(\"\"\"In this study, we examined the effects of mitiglinide on various cloned K(ATP) channels\n",
    "     (Kir6.2/SUR1, Kir6.2/SUR2A, and Kir6.2/SUR2B) reconstituted in COS-1 cells, and compared them to another meglitinide-related compound, nateglinide. Patch-clamp analysis using\n",
    "     inside-out recording configuration showed that mitiglinide inhibits the Kir6.2/SUR1 channel currents in a dose-dependent manner (IC50 value, 100 nM) but does not significantly\n",
    "     inhibit either Kir6.2/SUR2A or Kir6.2/SUR2B channel currents even at high doses (more than 10 microM). Nateglinide inhibits Kir6.2/SUR1 and Kir6.2/SUR2B channels at 100 nM,\n",
    "     and inhibits Kir6.2/SUR2A channels at high concentrations (1 microM). Binding experiments on mitiglinide, nateglinide, and repaglinide to SUR1 expressed in COS-1 cells\n",
    "     revealed that they inhibit the binding of [3H]glibenclamide to SUR1 (IC50 values: mitiglinide, 280 nM; nateglinide, 8 microM; repaglinide, 1.6 microM), suggesting that\n",
    "     they all share a glibenclamide binding site. The insulin responses to glucose, mitiglinide, tolbutamide, and glibenclamide in MIN6 cells after chronic mitiglinide, nateglinide,\n",
    "     or repaglinide treatment were comparable to those after chronic tolbutamide and glibenclamide treatment. These results indicate that, similar to the sulfonylureas, mitiglinide\n",
    "     is highly specific to the Kir6.2/SUR1 complex, i.e., the pancreatic beta-cell K(ATP) channel,\n",
    "     and suggest that mitiglinide may be a clinically useful anti-diabetic drug.\"\"\", output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "3oTheptkxL1i"
   },
   "source": [
    "#### [Extract relations between problem, treatment and test entities (ReDL)](https://nlp.johnsnowlabs.com/2021/02/04/redl_clinical_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "xfAcS99-xL1i",
    "outputId": "3fa07463-7dec-472e-a1ce-b2f7fa57fc89"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_clinical_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-6848e502-f2f7-4a88-a572-2578cdbde5d9\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_clinical</th>\n",
       "      <th>entities_clinical_class</th>\n",
       "      <th>entities_clinical_confidence</th>\n",
       "      <th>entities_clinical_origin_chunk</th>\n",
       "      <th>entities_clinical_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>O</td>\n",
       "      <td>0.6245477</td>\n",
       "      <td>gestational diabetes mellitus</td>\n",
       "      <td>39</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>67</td>\n",
       "      <td>subsequent type two diabetes mellitus</td>\n",
       "      <td>117</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>153</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>PIP</td>\n",
       "      <td>0.61894315</td>\n",
       "      <td>gestational diabetes mellitus</td>\n",
       "      <td>39</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>67</td>\n",
       "      <td>T2DM</td>\n",
       "      <td>157</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>160</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>PIP</td>\n",
       "      <td>0.67223376</td>\n",
       "      <td>gestational diabetes mellitus</td>\n",
       "      <td>39</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>67</td>\n",
       "      <td>HTG-induced pancreatitis</td>\n",
       "      <td>186</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>209</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>PIP</td>\n",
       "      <td>0.8902972</td>\n",
       "      <td>gestational diabetes mellitus</td>\n",
       "      <td>39</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>67</td>\n",
       "      <td>an acute hepatitis</td>\n",
       "      <td>262</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>279</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>PIP</td>\n",
       "      <td>0.7641642</td>\n",
       "      <td>gestational diabetes mellitus</td>\n",
       "      <td>39</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>67</td>\n",
       "      <td>obesity</td>\n",
       "      <td>287</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>293</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>O</td>\n",
       "      <td>0.98002785</td>\n",
       "      <td>polyuria</td>\n",
       "      <td>379</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>386</td>\n",
       "      <td>poor appetite</td>\n",
       "      <td>403</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>415</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>O</td>\n",
       "      <td>0.9856434</td>\n",
       "      <td>polyuria</td>\n",
       "      <td>379</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>386</td>\n",
       "      <td>vomiting</td>\n",
       "      <td>423</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>430</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>O</td>\n",
       "      <td>0.9899935</td>\n",
       "      <td>polydipsia</td>\n",
       "      <td>390</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>399</td>\n",
       "      <td>poor appetite</td>\n",
       "      <td>403</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>415</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>O</td>\n",
       "      <td>0.9912401</td>\n",
       "      <td>polydipsia</td>\n",
       "      <td>390</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>399</td>\n",
       "      <td>vomiting</td>\n",
       "      <td>423</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>430</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A 28-year-old female with a history of gestati...</td>\n",
       "      <td>[gestational diabetes mellitus, subsequent typ...</td>\n",
       "      <td>[PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...</td>\n",
       "      <td>[0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>O</td>\n",
       "      <td>0.9928635</td>\n",
       "      <td>poor appetite</td>\n",
       "      <td>403</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>415</td>\n",
       "      <td>vomiting</td>\n",
       "      <td>423</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>430</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.040217556059360504, 0.4003961980342865, 0....</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>63 rows × 18 columns</p>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-6848e502-f2f7-4a88-a572-2578cdbde5d9')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-6848e502-f2f7-4a88-a572-2578cdbde5d9 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-6848e502-f2f7-4a88-a572-2578cdbde5d9');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-2c802080-74c5-4b5d-b65c-92549d24fdc6\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-2c802080-74c5-4b5d-b65c-92549d24fdc6')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-2c802080-74c5-4b5d-b65c-92549d24fdc6 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                             document  \\\n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "..                                                ...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "0   A 28-year-old female with a history of gestati...   \n",
       "\n",
       "                                    entities_clinical  \\\n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "..                                                ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "0   [gestational diabetes mellitus, subsequent typ...   \n",
       "\n",
       "                              entities_clinical_class  \\\n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "..                                                ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "0   [PROBLEM, PROBLEM, PROBLEM, PROBLEM, PROBLEM, ...   \n",
       "\n",
       "                         entities_clinical_confidence  \\\n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "..                                                ...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "0   [0.9205, 0.75560004, 0.9928, 0.97975004, 0.951...   \n",
       "\n",
       "            entities_clinical_origin_chunk  \\\n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "..                                     ...   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]   \n",
       "\n",
       "       entities_clinical_origin_sentence relation relation_confidence  \\\n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]        O           0.6245477   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]      PIP          0.61894315   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]      PIP          0.67223376   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]      PIP           0.8902972   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]      PIP           0.7641642   \n",
       "..                                   ...      ...                 ...   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]        O          0.98002785   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]        O           0.9856434   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]        O           0.9899935   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]        O           0.9912401   \n",
       "0   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]        O           0.9928635   \n",
       "\n",
       "                 relation_entity1 relation_entity1_begin  \\\n",
       "0   gestational diabetes mellitus                     39   \n",
       "0   gestational diabetes mellitus                     39   \n",
       "0   gestational diabetes mellitus                     39   \n",
       "0   gestational diabetes mellitus                     39   \n",
       "0   gestational diabetes mellitus                     39   \n",
       "..                            ...                    ...   \n",
       "0                        polyuria                    379   \n",
       "0                        polyuria                    379   \n",
       "0                      polydipsia                    390   \n",
       "0                      polydipsia                    390   \n",
       "0                   poor appetite                    403   \n",
       "\n",
       "   relation_entity1_class relation_entity1_end  \\\n",
       "0                 PROBLEM                   67   \n",
       "0                 PROBLEM                   67   \n",
       "0                 PROBLEM                   67   \n",
       "0                 PROBLEM                   67   \n",
       "0                 PROBLEM                   67   \n",
       "..                    ...                  ...   \n",
       "0                 PROBLEM                  386   \n",
       "0                 PROBLEM                  386   \n",
       "0                 PROBLEM                  399   \n",
       "0                 PROBLEM                  399   \n",
       "0                 PROBLEM                  415   \n",
       "\n",
       "                         relation_entity2 relation_entity2_begin  \\\n",
       "0   subsequent type two diabetes mellitus                    117   \n",
       "0                                    T2DM                    157   \n",
       "0                HTG-induced pancreatitis                    186   \n",
       "0                      an acute hepatitis                    262   \n",
       "0                                 obesity                    287   \n",
       "..                                    ...                    ...   \n",
       "0                           poor appetite                    403   \n",
       "0                                vomiting                    423   \n",
       "0                           poor appetite                    403   \n",
       "0                                vomiting                    423   \n",
       "0                                vomiting                    423   \n",
       "\n",
       "   relation_entity2_class relation_entity2_end relation_origin_sentence  \\\n",
       "0                 PROBLEM                  153                        0   \n",
       "0                 PROBLEM                  160                        0   \n",
       "0                 PROBLEM                  209                        0   \n",
       "0                 PROBLEM                  279                        0   \n",
       "0                 PROBLEM                  293                        0   \n",
       "..                    ...                  ...                      ...   \n",
       "0                 PROBLEM                  415                        0   \n",
       "0                 PROBLEM                  430                        0   \n",
       "0                 PROBLEM                  415                        0   \n",
       "0                 PROBLEM                  430                        0   \n",
       "0                 PROBLEM                  430                        0   \n",
       "\n",
       "                                 word_embedding_glove  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "..                                                ...  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "0   [[0.040217556059360504, 0.4003961980342865, 0....  \n",
       "\n",
       "[63 rows x 18 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.clinical en.relation.clinical').predict(\"\"\"A 28-year-old female with a history of gestational diabetes mellitus diagnosed eight years prior to presentation\n",
    "and subsequent type two diabetes mellitus ( T2DM ), one prior episode of HTG-induced pancreatitis three years prior to presentation,  associated with an acute hepatitis , and obesity with a body mass\n",
    "index ( BMI ) of 33.5 kg/m2 , presented with a one-week history of polyuria , polydipsia , poor appetite , and vomiting .\n",
    "\"\"\", output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "nYn8GPXUxL81"
   },
   "source": [
    "#### [Extract temporal relations among clinical events (ReDL)](https://nlp.johnsnowlabs.com/2021/02/04/redl_temporal_events_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "vUR8da-7xL82",
    "outputId": "abbcdb6b-2b6f-4bd3-e85f-81567f01bdbb"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_events_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_temporal_events_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-98b74334-e4f1-4239-92c3-8d5d35cca6a7\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_events_clinical</th>\n",
       "      <th>entities_events_clinical_class</th>\n",
       "      <th>entities_events_clinical_confidence</th>\n",
       "      <th>entities_events_clinical_origin_chunk</th>\n",
       "      <th>entities_events_clinical_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.66990185</td>\n",
       "      <td>diagnosed</td>\n",
       "      <td>7</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>15</td>\n",
       "      <td>cancer</td>\n",
       "      <td>22</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>27</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.5236299</td>\n",
       "      <td>diagnosed</td>\n",
       "      <td>7</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>15</td>\n",
       "      <td>1991</td>\n",
       "      <td>32</td>\n",
       "      <td>DATE</td>\n",
       "      <td>35</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.5183793</td>\n",
       "      <td>diagnosed</td>\n",
       "      <td>7</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>15</td>\n",
       "      <td>admitted</td>\n",
       "      <td>51</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>58</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.63696253</td>\n",
       "      <td>diagnosed</td>\n",
       "      <td>7</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>15</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.76419973</td>\n",
       "      <td>cancer</td>\n",
       "      <td>22</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>27</td>\n",
       "      <td>1991</td>\n",
       "      <td>32</td>\n",
       "      <td>DATE</td>\n",
       "      <td>35</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.51728874</td>\n",
       "      <td>cancer</td>\n",
       "      <td>22</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>27</td>\n",
       "      <td>admitted</td>\n",
       "      <td>51</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>58</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.6379777</td>\n",
       "      <td>cancer</td>\n",
       "      <td>22</td>\n",
       "      <td>PROBLEM</td>\n",
       "      <td>27</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.55314463</td>\n",
       "      <td>1991</td>\n",
       "      <td>32</td>\n",
       "      <td>DATE</td>\n",
       "      <td>35</td>\n",
       "      <td>Mayo Clinic</td>\n",
       "      <td>63</td>\n",
       "      <td>CLINICAL_DEPT</td>\n",
       "      <td>73</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.62730515</td>\n",
       "      <td>1991</td>\n",
       "      <td>32</td>\n",
       "      <td>DATE</td>\n",
       "      <td>35</td>\n",
       "      <td>May 2000</td>\n",
       "      <td>78</td>\n",
       "      <td>DATE</td>\n",
       "      <td>85</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.50219613</td>\n",
       "      <td>1991</td>\n",
       "      <td>32</td>\n",
       "      <td>DATE</td>\n",
       "      <td>35</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.61136776</td>\n",
       "      <td>1991</td>\n",
       "      <td>32</td>\n",
       "      <td>DATE</td>\n",
       "      <td>35</td>\n",
       "      <td>October 2001</td>\n",
       "      <td>105</td>\n",
       "      <td>DATE</td>\n",
       "      <td>116</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>AFTER</td>\n",
       "      <td>0.7413282</td>\n",
       "      <td>admitted</td>\n",
       "      <td>51</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>58</td>\n",
       "      <td>Mayo Clinic</td>\n",
       "      <td>63</td>\n",
       "      <td>CLINICAL_DEPT</td>\n",
       "      <td>73</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.6036349</td>\n",
       "      <td>admitted</td>\n",
       "      <td>51</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>58</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.69977224</td>\n",
       "      <td>Mayo Clinic</td>\n",
       "      <td>63</td>\n",
       "      <td>CLINICAL_DEPT</td>\n",
       "      <td>73</td>\n",
       "      <td>May 2000</td>\n",
       "      <td>78</td>\n",
       "      <td>DATE</td>\n",
       "      <td>85</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.520515</td>\n",
       "      <td>Mayo Clinic</td>\n",
       "      <td>63</td>\n",
       "      <td>CLINICAL_DEPT</td>\n",
       "      <td>73</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.54951686</td>\n",
       "      <td>Mayo Clinic</td>\n",
       "      <td>63</td>\n",
       "      <td>CLINICAL_DEPT</td>\n",
       "      <td>73</td>\n",
       "      <td>October 2001</td>\n",
       "      <td>105</td>\n",
       "      <td>DATE</td>\n",
       "      <td>116</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.50707734</td>\n",
       "      <td>May 2000</td>\n",
       "      <td>78</td>\n",
       "      <td>DATE</td>\n",
       "      <td>85</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>OVERLAP</td>\n",
       "      <td>0.6101387</td>\n",
       "      <td>May 2000</td>\n",
       "      <td>78</td>\n",
       "      <td>DATE</td>\n",
       "      <td>85</td>\n",
       "      <td>October 2001</td>\n",
       "      <td>105</td>\n",
       "      <td>DATE</td>\n",
       "      <td>116</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She is diagnosed with cancer in 1991. Then she...</td>\n",
       "      <td>[diagnosed, cancer, 1991, admitted, Mayo Clini...</td>\n",
       "      <td>[OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...</td>\n",
       "      <td>[0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>BEFORE</td>\n",
       "      <td>0.52927303</td>\n",
       "      <td>discharged</td>\n",
       "      <td>91</td>\n",
       "      <td>OCCURRENCE</td>\n",
       "      <td>100</td>\n",
       "      <td>October 2001</td>\n",
       "      <td>105</td>\n",
       "      <td>DATE</td>\n",
       "      <td>116</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-98b74334-e4f1-4239-92c3-8d5d35cca6a7')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-98b74334-e4f1-4239-92c3-8d5d35cca6a7 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-98b74334-e4f1-4239-92c3-8d5d35cca6a7');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-755028b7-e361-4e68-94cf-670404f3df0b\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-755028b7-e361-4e68-94cf-670404f3df0b')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-755028b7-e361-4e68-94cf-670404f3df0b button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "0  She is diagnosed with cancer in 1991. Then she...   \n",
       "\n",
       "                            entities_events_clinical  \\\n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "0  [diagnosed, cancer, 1991, admitted, Mayo Clini...   \n",
       "\n",
       "                      entities_events_clinical_class  \\\n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "0  [OCCURRENCE, PROBLEM, DATE, OCCURRENCE, CLINIC...   \n",
       "\n",
       "                 entities_events_clinical_confidence  \\\n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "0  [0.833, 0.9918, 0.9883, 0.9685, 0.8914, 0.9335...   \n",
       "\n",
       "  entities_events_clinical_origin_chunk  \\\n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "0              [0, 1, 2, 3, 4, 5, 6, 7]   \n",
       "\n",
       "  entities_events_clinical_origin_sentence relation relation_confidence  \\\n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE          0.66990185   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP           0.5236299   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE           0.5183793   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE          0.63696253   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP          0.76419973   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE          0.51728874   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE           0.6379777   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP          0.55314463   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP          0.62730515   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE          0.50219613   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP          0.61136776   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]    AFTER           0.7413282   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE           0.6036349   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP          0.69977224   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE            0.520515   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP          0.54951686   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE          0.50707734   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]  OVERLAP           0.6101387   \n",
       "0                 [0, 0, 0, 0, 0, 0, 0, 0]   BEFORE          0.52927303   \n",
       "\n",
       "  relation_entity1 relation_entity1_begin relation_entity1_class  \\\n",
       "0        diagnosed                      7             OCCURRENCE   \n",
       "0        diagnosed                      7             OCCURRENCE   \n",
       "0        diagnosed                      7             OCCURRENCE   \n",
       "0        diagnosed                      7             OCCURRENCE   \n",
       "0           cancer                     22                PROBLEM   \n",
       "0           cancer                     22                PROBLEM   \n",
       "0           cancer                     22                PROBLEM   \n",
       "0             1991                     32                   DATE   \n",
       "0             1991                     32                   DATE   \n",
       "0             1991                     32                   DATE   \n",
       "0             1991                     32                   DATE   \n",
       "0         admitted                     51             OCCURRENCE   \n",
       "0         admitted                     51             OCCURRENCE   \n",
       "0      Mayo Clinic                     63          CLINICAL_DEPT   \n",
       "0      Mayo Clinic                     63          CLINICAL_DEPT   \n",
       "0      Mayo Clinic                     63          CLINICAL_DEPT   \n",
       "0         May 2000                     78                   DATE   \n",
       "0         May 2000                     78                   DATE   \n",
       "0       discharged                     91             OCCURRENCE   \n",
       "\n",
       "  relation_entity1_end relation_entity2 relation_entity2_begin  \\\n",
       "0                   15           cancer                     22   \n",
       "0                   15             1991                     32   \n",
       "0                   15         admitted                     51   \n",
       "0                   15       discharged                     91   \n",
       "0                   27             1991                     32   \n",
       "0                   27         admitted                     51   \n",
       "0                   27       discharged                     91   \n",
       "0                   35      Mayo Clinic                     63   \n",
       "0                   35         May 2000                     78   \n",
       "0                   35       discharged                     91   \n",
       "0                   35     October 2001                    105   \n",
       "0                   58      Mayo Clinic                     63   \n",
       "0                   58       discharged                     91   \n",
       "0                   73         May 2000                     78   \n",
       "0                   73       discharged                     91   \n",
       "0                   73     October 2001                    105   \n",
       "0                   85       discharged                     91   \n",
       "0                   85     October 2001                    105   \n",
       "0                  100     October 2001                    105   \n",
       "\n",
       "  relation_entity2_class relation_entity2_end relation_origin_sentence  \\\n",
       "0                PROBLEM                   27                        0   \n",
       "0                   DATE                   35                        0   \n",
       "0             OCCURRENCE                   58                        0   \n",
       "0             OCCURRENCE                  100                        0   \n",
       "0                   DATE                   35                        0   \n",
       "0             OCCURRENCE                   58                        0   \n",
       "0             OCCURRENCE                  100                        0   \n",
       "0          CLINICAL_DEPT                   73                        0   \n",
       "0                   DATE                   85                        0   \n",
       "0             OCCURRENCE                  100                        0   \n",
       "0                   DATE                  116                        0   \n",
       "0          CLINICAL_DEPT                   73                        0   \n",
       "0             OCCURRENCE                  100                        0   \n",
       "0                   DATE                   85                        0   \n",
       "0             OCCURRENCE                  100                        0   \n",
       "0                   DATE                  116                        0   \n",
       "0             OCCURRENCE                  100                        0   \n",
       "0                   DATE                  116                        0   \n",
       "0                   DATE                  116                        0   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.events_clinical en.relation.temporal_events').predict(\"She is diagnosed with cancer in 1991. Then she was admitted to Mayo Clinic in May 2000 and discharged in October 2001\", output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "4cdL0bFSxMDq"
   },
   "source": [
    "#### [Extract relations between phenotypic abnormalities and diseases (ReDL)](https://nlp.johnsnowlabs.com/2021/02/04/redl_human_phenotype_gene_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "IYT1_iwMxMDr",
    "outputId": "dee2f928-2cce-4586-d428-2e777a6082da"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_human_phenotype_gene_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_human_phenotype_gene_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-6783665e-4e15-4c40-9814-55e4da512120\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_human_phenotype</th>\n",
       "      <th>entities_human_phenotype_class</th>\n",
       "      <th>entities_human_phenotype_confidence</th>\n",
       "      <th>entities_human_phenotype_origin_chunk</th>\n",
       "      <th>entities_human_phenotype_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.71494997</td>\n",
       "      <td>retinal degeneration</td>\n",
       "      <td>10</td>\n",
       "      <td>HP</td>\n",
       "      <td>29</td>\n",
       "      <td>hearing loss</td>\n",
       "      <td>32</td>\n",
       "      <td>HP</td>\n",
       "      <td>43</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.71494997</td>\n",
       "      <td>retinal degeneration</td>\n",
       "      <td>10</td>\n",
       "      <td>HP</td>\n",
       "      <td>29</td>\n",
       "      <td>renal failure</td>\n",
       "      <td>49</td>\n",
       "      <td>HP</td>\n",
       "      <td>61</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.71494997</td>\n",
       "      <td>retinal degeneration</td>\n",
       "      <td>10</td>\n",
       "      <td>HP</td>\n",
       "      <td>29</td>\n",
       "      <td>short stature</td>\n",
       "      <td>64</td>\n",
       "      <td>HP</td>\n",
       "      <td>76</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.71494997</td>\n",
       "      <td>retinal degeneration</td>\n",
       "      <td>10</td>\n",
       "      <td>HP</td>\n",
       "      <td>29</td>\n",
       "      <td>SH3PXD2B</td>\n",
       "      <td>96</td>\n",
       "      <td>GENE</td>\n",
       "      <td>103</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.71494997</td>\n",
       "      <td>retinal degeneration</td>\n",
       "      <td>10</td>\n",
       "      <td>HP</td>\n",
       "      <td>29</td>\n",
       "      <td>autosomal recessive</td>\n",
       "      <td>162</td>\n",
       "      <td>HP</td>\n",
       "      <td>180</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.76895</td>\n",
       "      <td>hearing loss</td>\n",
       "      <td>32</td>\n",
       "      <td>HP</td>\n",
       "      <td>43</td>\n",
       "      <td>renal failure</td>\n",
       "      <td>49</td>\n",
       "      <td>HP</td>\n",
       "      <td>61</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.76895</td>\n",
       "      <td>hearing loss</td>\n",
       "      <td>32</td>\n",
       "      <td>HP</td>\n",
       "      <td>43</td>\n",
       "      <td>short stature</td>\n",
       "      <td>64</td>\n",
       "      <td>HP</td>\n",
       "      <td>76</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.76895</td>\n",
       "      <td>hearing loss</td>\n",
       "      <td>32</td>\n",
       "      <td>HP</td>\n",
       "      <td>43</td>\n",
       "      <td>SH3PXD2B</td>\n",
       "      <td>96</td>\n",
       "      <td>GENE</td>\n",
       "      <td>103</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.76895</td>\n",
       "      <td>hearing loss</td>\n",
       "      <td>32</td>\n",
       "      <td>HP</td>\n",
       "      <td>43</td>\n",
       "      <td>autosomal recessive</td>\n",
       "      <td>162</td>\n",
       "      <td>HP</td>\n",
       "      <td>180</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.7631</td>\n",
       "      <td>renal failure</td>\n",
       "      <td>49</td>\n",
       "      <td>HP</td>\n",
       "      <td>61</td>\n",
       "      <td>short stature</td>\n",
       "      <td>64</td>\n",
       "      <td>HP</td>\n",
       "      <td>76</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.7631</td>\n",
       "      <td>renal failure</td>\n",
       "      <td>49</td>\n",
       "      <td>HP</td>\n",
       "      <td>61</td>\n",
       "      <td>SH3PXD2B</td>\n",
       "      <td>96</td>\n",
       "      <td>GENE</td>\n",
       "      <td>103</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.7631</td>\n",
       "      <td>renal failure</td>\n",
       "      <td>49</td>\n",
       "      <td>HP</td>\n",
       "      <td>61</td>\n",
       "      <td>autosomal recessive</td>\n",
       "      <td>162</td>\n",
       "      <td>HP</td>\n",
       "      <td>180</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.8243</td>\n",
       "      <td>short stature</td>\n",
       "      <td>64</td>\n",
       "      <td>HP</td>\n",
       "      <td>76</td>\n",
       "      <td>SH3PXD2B</td>\n",
       "      <td>96</td>\n",
       "      <td>GENE</td>\n",
       "      <td>103</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.8243</td>\n",
       "      <td>short stature</td>\n",
       "      <td>64</td>\n",
       "      <td>HP</td>\n",
       "      <td>76</td>\n",
       "      <td>autosomal recessive</td>\n",
       "      <td>162</td>\n",
       "      <td>HP</td>\n",
       "      <td>180</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>She has a retinal degeneration, hearing loss a...</td>\n",
       "      <td>[retinal degeneration, hearing loss, renal fai...</td>\n",
       "      <td>[HP, HP, HP, HP, GENE, HP]</td>\n",
       "      <td>[0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.9994</td>\n",
       "      <td>SH3PXD2B</td>\n",
       "      <td>96</td>\n",
       "      <td>GENE</td>\n",
       "      <td>103</td>\n",
       "      <td>autosomal recessive</td>\n",
       "      <td>162</td>\n",
       "      <td>HP</td>\n",
       "      <td>180</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.21964989602565765, -0.2844458520412445, -...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-6783665e-4e15-4c40-9814-55e4da512120')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-6783665e-4e15-4c40-9814-55e4da512120 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-6783665e-4e15-4c40-9814-55e4da512120');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-4514497b-6d2f-4090-bebb-bfe532b8bf69\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-4514497b-6d2f-4090-bebb-bfe532b8bf69')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-4514497b-6d2f-4090-bebb-bfe532b8bf69 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "0  She has a retinal degeneration, hearing loss a...   \n",
       "\n",
       "                            entities_human_phenotype  \\\n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "0  [retinal degeneration, hearing loss, renal fai...   \n",
       "\n",
       "  entities_human_phenotype_class  \\\n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "0     [HP, HP, HP, HP, GENE, HP]   \n",
       "\n",
       "                 entities_human_phenotype_confidence  \\\n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "0  [0.71494997, 0.76895, 0.7631, 0.8243, 0.9994, ...   \n",
       "\n",
       "  entities_human_phenotype_origin_chunk  \\\n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "0                    [0, 1, 2, 3, 4, 5]   \n",
       "\n",
       "  entities_human_phenotype_origin_sentence relation relation_confidence  \\\n",
       "0                       [0, 0, 0, 0, 0, 0]        0          0.71494997   \n",
       "0                       [0, 0, 0, 0, 0, 0]        0          0.71494997   \n",
       "0                       [0, 0, 0, 0, 0, 0]        0          0.71494997   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1          0.71494997   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1          0.71494997   \n",
       "0                       [0, 0, 0, 0, 0, 0]        0             0.76895   \n",
       "0                       [0, 0, 0, 0, 0, 0]        0             0.76895   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1             0.76895   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1             0.76895   \n",
       "0                       [0, 0, 0, 0, 0, 0]        0              0.7631   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1              0.7631   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1              0.7631   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1              0.8243   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1              0.8243   \n",
       "0                       [0, 0, 0, 0, 0, 0]        1              0.9994   \n",
       "\n",
       "       relation_entity1 relation_entity1_begin relation_entity1_class  \\\n",
       "0  retinal degeneration                     10                     HP   \n",
       "0  retinal degeneration                     10                     HP   \n",
       "0  retinal degeneration                     10                     HP   \n",
       "0  retinal degeneration                     10                     HP   \n",
       "0  retinal degeneration                     10                     HP   \n",
       "0          hearing loss                     32                     HP   \n",
       "0          hearing loss                     32                     HP   \n",
       "0          hearing loss                     32                     HP   \n",
       "0          hearing loss                     32                     HP   \n",
       "0         renal failure                     49                     HP   \n",
       "0         renal failure                     49                     HP   \n",
       "0         renal failure                     49                     HP   \n",
       "0         short stature                     64                     HP   \n",
       "0         short stature                     64                     HP   \n",
       "0              SH3PXD2B                     96                   GENE   \n",
       "\n",
       "  relation_entity1_end     relation_entity2 relation_entity2_begin  \\\n",
       "0                   29         hearing loss                     32   \n",
       "0                   29        renal failure                     49   \n",
       "0                   29        short stature                     64   \n",
       "0                   29             SH3PXD2B                     96   \n",
       "0                   29  autosomal recessive                    162   \n",
       "0                   43        renal failure                     49   \n",
       "0                   43        short stature                     64   \n",
       "0                   43             SH3PXD2B                     96   \n",
       "0                   43  autosomal recessive                    162   \n",
       "0                   61        short stature                     64   \n",
       "0                   61             SH3PXD2B                     96   \n",
       "0                   61  autosomal recessive                    162   \n",
       "0                   76             SH3PXD2B                     96   \n",
       "0                   76  autosomal recessive                    162   \n",
       "0                  103  autosomal recessive                    162   \n",
       "\n",
       "  relation_entity2_class relation_entity2_end relation_origin_sentence  \\\n",
       "0                     HP                   43                        0   \n",
       "0                     HP                   61                        0   \n",
       "0                     HP                   76                        0   \n",
       "0                   GENE                  103                        0   \n",
       "0                     HP                  180                        0   \n",
       "0                     HP                   61                        0   \n",
       "0                     HP                   76                        0   \n",
       "0                   GENE                  103                        0   \n",
       "0                     HP                  180                        0   \n",
       "0                     HP                   76                        0   \n",
       "0                   GENE                  103                        0   \n",
       "0                     HP                  180                        0   \n",
       "0                   GENE                  103                        0   \n",
       "0                     HP                  180                        0   \n",
       "0                     HP                  180                        0   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  \n",
       "0  [[-0.21964989602565765, -0.2844458520412445, -...  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.human_phenotype.gene_clinical en.relation.humen_phenotype_gene').predict(\"She has a retinal degeneration, hearing loss and renal failure, short stature, \\\n",
    "Mutations in the SH3PXD2B gene coding for the Tks4 protein are responsible for the autosomal recessive.\", output_level='relation')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "uqUgvXYzxMHv"
   },
   "source": [
    "#### [Extract relations between effects of using multiple drugs (ReDL)](https://nlp.johnsnowlabs.com/2021/02/04/redl_drug_drug_interaction_biobert_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 848
    },
    "id": "-XszdVrxxMHw",
    "outputId": "f9982c5f-b4ff-4bef-eb4e-29f4b0f623bb"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_posology download started this may take some time.\n",
      "[OK!]\n",
      "redl_drug_drug_interaction_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-2cad587a-80a5-4d2f-9b08-715f1b0c4af9\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_posology</th>\n",
       "      <th>entities_posology_class</th>\n",
       "      <th>entities_posology_confidence</th>\n",
       "      <th>entities_posology_origin_chunk</th>\n",
       "      <th>entities_posology_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>When carbamazepine is withdrawn from the combi...</td>\n",
       "      <td>[carbamazepine, aripiprazole, adrenergic drugs...</td>\n",
       "      <td>[DRUG, DRUG, DRUG, DRUG]</td>\n",
       "      <td>[0.9973, 0.9998, 0.6996, 0.9998]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>DDI-false</td>\n",
       "      <td>0.9973</td>\n",
       "      <td>carbamazepine</td>\n",
       "      <td>5</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>17</td>\n",
       "      <td>aripiprazole</td>\n",
       "      <td>62</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>73</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.06080734729766846, -0.2955009639263153, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>When carbamazepine is withdrawn from the combi...</td>\n",
       "      <td>[carbamazepine, aripiprazole, adrenergic drugs...</td>\n",
       "      <td>[DRUG, DRUG, DRUG, DRUG]</td>\n",
       "      <td>[0.9973, 0.9998, 0.6996, 0.9998]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>DDI-false</td>\n",
       "      <td>0.9973</td>\n",
       "      <td>carbamazepine</td>\n",
       "      <td>5</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>17</td>\n",
       "      <td>adrenergic drugs</td>\n",
       "      <td>118</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>133</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.06080734729766846, -0.2955009639263153, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>When carbamazepine is withdrawn from the combi...</td>\n",
       "      <td>[carbamazepine, aripiprazole, adrenergic drugs...</td>\n",
       "      <td>[DRUG, DRUG, DRUG, DRUG]</td>\n",
       "      <td>[0.9973, 0.9998, 0.6996, 0.9998]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>DDI-false</td>\n",
       "      <td>0.9973</td>\n",
       "      <td>carbamazepine</td>\n",
       "      <td>5</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>17</td>\n",
       "      <td>Metformin</td>\n",
       "      <td>270</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>278</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.06080734729766846, -0.2955009639263153, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>When carbamazepine is withdrawn from the combi...</td>\n",
       "      <td>[carbamazepine, aripiprazole, adrenergic drugs...</td>\n",
       "      <td>[DRUG, DRUG, DRUG, DRUG]</td>\n",
       "      <td>[0.9973, 0.9998, 0.6996, 0.9998]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>DDI-false</td>\n",
       "      <td>0.9998</td>\n",
       "      <td>aripiprazole</td>\n",
       "      <td>62</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>73</td>\n",
       "      <td>adrenergic drugs</td>\n",
       "      <td>118</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>133</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.06080734729766846, -0.2955009639263153, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>When carbamazepine is withdrawn from the combi...</td>\n",
       "      <td>[carbamazepine, aripiprazole, adrenergic drugs...</td>\n",
       "      <td>[DRUG, DRUG, DRUG, DRUG]</td>\n",
       "      <td>[0.9973, 0.9998, 0.6996, 0.9998]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>DDI-false</td>\n",
       "      <td>0.9998</td>\n",
       "      <td>aripiprazole</td>\n",
       "      <td>62</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>73</td>\n",
       "      <td>Metformin</td>\n",
       "      <td>270</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>278</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.06080734729766846, -0.2955009639263153, -...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>When carbamazepine is withdrawn from the combi...</td>\n",
       "      <td>[carbamazepine, aripiprazole, adrenergic drugs...</td>\n",
       "      <td>[DRUG, DRUG, DRUG, DRUG]</td>\n",
       "      <td>[0.9973, 0.9998, 0.6996, 0.9998]</td>\n",
       "      <td>[0, 1, 2, 3]</td>\n",
       "      <td>[0, 0, 0, 0]</td>\n",
       "      <td>DDI-effect</td>\n",
       "      <td>0.6996</td>\n",
       "      <td>adrenergic drugs</td>\n",
       "      <td>118</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>133</td>\n",
       "      <td>Metformin</td>\n",
       "      <td>270</td>\n",
       "      <td>DRUG</td>\n",
       "      <td>278</td>\n",
       "      <td>0</td>\n",
       "      <td>[[-0.06080734729766846, -0.2955009639263153, -...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-2cad587a-80a5-4d2f-9b08-715f1b0c4af9')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-2cad587a-80a5-4d2f-9b08-715f1b0c4af9 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-2cad587a-80a5-4d2f-9b08-715f1b0c4af9');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-c1864b78-e326-42e6-a88c-2d5f47f0f8f0\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-c1864b78-e326-42e6-a88c-2d5f47f0f8f0')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-c1864b78-e326-42e6-a88c-2d5f47f0f8f0 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  When carbamazepine is withdrawn from the combi...   \n",
       "0  When carbamazepine is withdrawn from the combi...   \n",
       "0  When carbamazepine is withdrawn from the combi...   \n",
       "0  When carbamazepine is withdrawn from the combi...   \n",
       "0  When carbamazepine is withdrawn from the combi...   \n",
       "0  When carbamazepine is withdrawn from the combi...   \n",
       "\n",
       "                                   entities_posology  \\\n",
       "0  [carbamazepine, aripiprazole, adrenergic drugs...   \n",
       "0  [carbamazepine, aripiprazole, adrenergic drugs...   \n",
       "0  [carbamazepine, aripiprazole, adrenergic drugs...   \n",
       "0  [carbamazepine, aripiprazole, adrenergic drugs...   \n",
       "0  [carbamazepine, aripiprazole, adrenergic drugs...   \n",
       "0  [carbamazepine, aripiprazole, adrenergic drugs...   \n",
       "\n",
       "    entities_posology_class      entities_posology_confidence  \\\n",
       "0  [DRUG, DRUG, DRUG, DRUG]  [0.9973, 0.9998, 0.6996, 0.9998]   \n",
       "0  [DRUG, DRUG, DRUG, DRUG]  [0.9973, 0.9998, 0.6996, 0.9998]   \n",
       "0  [DRUG, DRUG, DRUG, DRUG]  [0.9973, 0.9998, 0.6996, 0.9998]   \n",
       "0  [DRUG, DRUG, DRUG, DRUG]  [0.9973, 0.9998, 0.6996, 0.9998]   \n",
       "0  [DRUG, DRUG, DRUG, DRUG]  [0.9973, 0.9998, 0.6996, 0.9998]   \n",
       "0  [DRUG, DRUG, DRUG, DRUG]  [0.9973, 0.9998, 0.6996, 0.9998]   \n",
       "\n",
       "  entities_posology_origin_chunk entities_posology_origin_sentence  \\\n",
       "0                   [0, 1, 2, 3]                      [0, 0, 0, 0]   \n",
       "0                   [0, 1, 2, 3]                      [0, 0, 0, 0]   \n",
       "0                   [0, 1, 2, 3]                      [0, 0, 0, 0]   \n",
       "0                   [0, 1, 2, 3]                      [0, 0, 0, 0]   \n",
       "0                   [0, 1, 2, 3]                      [0, 0, 0, 0]   \n",
       "0                   [0, 1, 2, 3]                      [0, 0, 0, 0]   \n",
       "\n",
       "     relation relation_confidence  relation_entity1 relation_entity1_begin  \\\n",
       "0   DDI-false              0.9973     carbamazepine                      5   \n",
       "0   DDI-false              0.9973     carbamazepine                      5   \n",
       "0   DDI-false              0.9973     carbamazepine                      5   \n",
       "0   DDI-false              0.9998      aripiprazole                     62   \n",
       "0   DDI-false              0.9998      aripiprazole                     62   \n",
       "0  DDI-effect              0.6996  adrenergic drugs                    118   \n",
       "\n",
       "  relation_entity1_class relation_entity1_end  relation_entity2  \\\n",
       "0                   DRUG                   17      aripiprazole   \n",
       "0                   DRUG                   17  adrenergic drugs   \n",
       "0                   DRUG                   17         Metformin   \n",
       "0                   DRUG                   73  adrenergic drugs   \n",
       "0                   DRUG                   73         Metformin   \n",
       "0                   DRUG                  133         Metformin   \n",
       "\n",
       "  relation_entity2_begin relation_entity2_class relation_entity2_end  \\\n",
       "0                     62                   DRUG                   73   \n",
       "0                    118                   DRUG                  133   \n",
       "0                    270                   DRUG                  278   \n",
       "0                    118                   DRUG                  133   \n",
       "0                    270                   DRUG                  278   \n",
       "0                    270                   DRUG                  278   \n",
       "\n",
       "  relation_origin_sentence                               word_embedding_glove  \n",
       "0                        0  [[-0.06080734729766846, -0.2955009639263153, -...  \n",
       "0                        0  [[-0.06080734729766846, -0.2955009639263153, -...  \n",
       "0                        0  [[-0.06080734729766846, -0.2955009639263153, -...  \n",
       "0                        0  [[-0.06080734729766846, -0.2955009639263153, -...  \n",
       "0                        0  [[-0.06080734729766846, -0.2955009639263153, -...  \n",
       "0                        0  [[-0.06080734729766846, -0.2955009639263153, -...  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load('en.med_ner.posology en.relation.drug_drug_interaction').predict(\"\"\"When carbamazepine is withdrawn from the combination therapy, aripiprazole dose should then be reduced. \\\n",
    "If additional adrenergic drugs are to be administered by any route, \\\n",
    "they should be used with caution because the pharmacologically predictable sympathetic effects of Metformin may be potentiated\"\"\", output_level='relation')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "UL8QsG8e32Gm",
    "outputId": "d5b91c3c-9f51-476e-f59c-67b1f3a253cd"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "jsl_ner_wip_greedy_clinical download started this may take some time.\n",
      "[OK!]\n",
      "redl_bodypart_direction_biobert download started this may take some time.\n",
      "[OK!]\n",
      "embeddings_clinical download started this may take some time.\n",
      "Approximate size to download 1.6 GB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-5e2075dc-7b25-4d5b-84e0-9d7d7a518bcf\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>entities_jsl</th>\n",
       "      <th>entities_jsl_class</th>\n",
       "      <th>entities_jsl_confidence</th>\n",
       "      <th>entities_jsl_origin_chunk</th>\n",
       "      <th>entities_jsl_origin_sentence</th>\n",
       "      <th>relation</th>\n",
       "      <th>relation_confidence</th>\n",
       "      <th>relation_entity1</th>\n",
       "      <th>relation_entity1_begin</th>\n",
       "      <th>relation_entity1_class</th>\n",
       "      <th>relation_entity1_end</th>\n",
       "      <th>relation_entity2</th>\n",
       "      <th>relation_entity2_begin</th>\n",
       "      <th>relation_entity2_class</th>\n",
       "      <th>relation_entity2_end</th>\n",
       "      <th>relation_origin_sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9979</td>\n",
       "      <td>MRI</td>\n",
       "      <td>0</td>\n",
       "      <td>Test</td>\n",
       "      <td>2</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.5062</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.5062</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.5062</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.5062</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.5062</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.5062</td>\n",
       "      <td>infarction</td>\n",
       "      <td>17</td>\n",
       "      <td>Disease_Syndrome_Disorder</td>\n",
       "      <td>26</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.2152</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2152</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2152</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2152</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2152</td>\n",
       "      <td>upper</td>\n",
       "      <td>35</td>\n",
       "      <td>Direction</td>\n",
       "      <td>39</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2636</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2636</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2636</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2636</td>\n",
       "      <td>brain stem</td>\n",
       "      <td>41</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>50</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.4775</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.4775</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.4775</td>\n",
       "      <td>left</td>\n",
       "      <td>54</td>\n",
       "      <td>Direction</td>\n",
       "      <td>57</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.8135</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0.8135</td>\n",
       "      <td>cerebellum</td>\n",
       "      <td>59</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>68</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MRI demonstrated infarction in the upper brain...</td>\n",
       "      <td>[MRI, infarction, upper, brain stem, left, cer...</td>\n",
       "      <td>[Test, Disease_Syndrome_Disorder, Direction, I...</td>\n",
       "      <td>[0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6, 7]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>1</td>\n",
       "      <td>0.5086</td>\n",
       "      <td>right</td>\n",
       "      <td>74</td>\n",
       "      <td>Direction</td>\n",
       "      <td>78</td>\n",
       "      <td>basil ganglia</td>\n",
       "      <td>80</td>\n",
       "      <td>Internal_organ_or_component</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>[[0.30669355392456055, -0.18632292747497559, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-5e2075dc-7b25-4d5b-84e0-9d7d7a518bcf')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-5e2075dc-7b25-4d5b-84e0-9d7d7a518bcf button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-5e2075dc-7b25-4d5b-84e0-9d7d7a518bcf');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-d5994a6c-e589-4876-abdd-4a76ba71fac5\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-d5994a6c-e589-4876-abdd-4a76ba71fac5')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-d5994a6c-e589-4876-abdd-4a76ba71fac5 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                            document  \\\n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "0  MRI demonstrated infarction in the upper brain...   \n",
       "\n",
       "                                        entities_jsl  \\\n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "0  [MRI, infarction, upper, brain stem, left, cer...   \n",
       "\n",
       "                                  entities_jsl_class  \\\n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "0  [Test, Disease_Syndrome_Disorder, Direction, I...   \n",
       "\n",
       "                             entities_jsl_confidence  \\\n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "0  [0.9979, 0.5062, 0.2152, 0.2636, 0.4775, 0.813...   \n",
       "\n",
       "  entities_jsl_origin_chunk entities_jsl_origin_sentence relation  \\\n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        0   \n",
       "0  [0, 1, 2, 3, 4, 5, 6, 7]     [0, 0, 0, 0, 0, 0, 0, 0]        1   \n",
       "\n",
       "  relation_confidence relation_entity1 relation_entity1_begin  \\\n",
       "0              0.9979              MRI                      0   \n",
       "0              0.9979              MRI                      0   \n",
       "0              0.9979              MRI                      0   \n",
       "0              0.9979              MRI                      0   \n",
       "0              0.9979              MRI                      0   \n",
       "0              0.9979              MRI                      0   \n",
       "0              0.9979              MRI                      0   \n",
       "0              0.5062       infarction                     17   \n",
       "0              0.5062       infarction                     17   \n",
       "0              0.5062       infarction                     17   \n",
       "0              0.5062       infarction                     17   \n",
       "0              0.5062       infarction                     17   \n",
       "0              0.5062       infarction                     17   \n",
       "0              0.2152            upper                     35   \n",
       "0              0.2152            upper                     35   \n",
       "0              0.2152            upper                     35   \n",
       "0              0.2152            upper                     35   \n",
       "0              0.2152            upper                     35   \n",
       "0              0.2636       brain stem                     41   \n",
       "0              0.2636       brain stem                     41   \n",
       "0              0.2636       brain stem                     41   \n",
       "0              0.2636       brain stem                     41   \n",
       "0              0.4775             left                     54   \n",
       "0              0.4775             left                     54   \n",
       "0              0.4775             left                     54   \n",
       "0              0.8135       cerebellum                     59   \n",
       "0              0.8135       cerebellum                     59   \n",
       "0              0.5086            right                     74   \n",
       "\n",
       "        relation_entity1_class relation_entity1_end relation_entity2  \\\n",
       "0                         Test                    2       infarction   \n",
       "0                         Test                    2            upper   \n",
       "0                         Test                    2       brain stem   \n",
       "0                         Test                    2             left   \n",
       "0                         Test                    2       cerebellum   \n",
       "0                         Test                    2            right   \n",
       "0                         Test                    2    basil ganglia   \n",
       "0    Disease_Syndrome_Disorder                   26            upper   \n",
       "0    Disease_Syndrome_Disorder                   26       brain stem   \n",
       "0    Disease_Syndrome_Disorder                   26             left   \n",
       "0    Disease_Syndrome_Disorder                   26       cerebellum   \n",
       "0    Disease_Syndrome_Disorder                   26            right   \n",
       "0    Disease_Syndrome_Disorder                   26    basil ganglia   \n",
       "0                    Direction                   39       brain stem   \n",
       "0                    Direction                   39             left   \n",
       "0                    Direction                   39       cerebellum   \n",
       "0                    Direction                   39            right   \n",
       "0                    Direction                   39    basil ganglia   \n",
       "0  Internal_organ_or_component                   50             left   \n",
       "0  Internal_organ_or_component                   50       cerebellum   \n",
       "0  Internal_organ_or_component                   50            right   \n",
       "0  Internal_organ_or_component                   50    basil ganglia   \n",
       "0                    Direction                   57       cerebellum   \n",
       "0                    Direction                   57            right   \n",
       "0                    Direction                   57    basil ganglia   \n",
       "0  Internal_organ_or_component                   68            right   \n",
       "0  Internal_organ_or_component                   68    basil ganglia   \n",
       "0                    Direction                   78    basil ganglia   \n",
       "\n",
       "  relation_entity2_begin       relation_entity2_class relation_entity2_end  \\\n",
       "0                     17    Disease_Syndrome_Disorder                   26   \n",
       "0                     35                    Direction                   39   \n",
       "0                     41  Internal_organ_or_component                   50   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     35                    Direction                   39   \n",
       "0                     41  Internal_organ_or_component                   50   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     41  Internal_organ_or_component                   50   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     54                    Direction                   57   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     59  Internal_organ_or_component                   68   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     74                    Direction                   78   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "0                     80  Internal_organ_or_component                   92   \n",
       "\n",
       "  relation_origin_sentence                               word_embedding_glove  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  \n",
       "0                        0  [[0.30669355392456055, -0.18632292747497559, 0...  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = nlp.load('en.med_ner.jsl.wip.clinical.greedy en.relation').predict('MRI demonstrated infarction in the upper brain stem , left cerebellum and  right basil ganglia\"', output_level='relation')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "owOC2dyRnowG"
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
